```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据库高级特性详解 - 视图、索引、触发器与存储过程</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        :root {
            --primary: #4F46E5;
            --secondary: #10B981;
            --accent: #F59E0B;
            --dark: #1F2937;
            --light: #F3F4F6;
        }
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.6;
            color: var(--dark);
            background-color: #FAFAFA;
        }
        .hero {
            background: linear-gradient(135deg, #6B7280 0%, #4F46E5 100%);
        }
        .code-block {
            background-color: #282C34;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .highlight {
            position: relative;
        }
        .highlight::before {
            content: '';
            position: absolute;
            left: -4px;
            top: 0;
            height: 100%;
            width: 4px;
            background-color: var(--accent);
            border-radius: 4px;
        }
        .feature-icon {
            width: 48px;
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(159, 122, 234, 0.1) 100%);
        }
        .toc-item {
            position: relative;
            padding-left: 1.5rem;
        }
        .toc-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background-color: var(--primary);
            opacity: 0.5;
        }
        .toc-item:hover::before {
            opacity: 1;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-4">数据库高级特性指南</h1>
                    <p class="text-xl text-blue-100 mb-8">掌握视图、索引、触发器与存储过程，提升数据库性能与管理效率</p>
                    <div class="flex space-x-4">
                        <a href="#views" class="bg-white text-indigo-700 px-6 py-3 rounded-lg font-medium hover:bg-indigo-50 transition duration-300">
                            <i class="fas fa-eye mr-2"></i>视图
                        </a>
                        <a href="#indexes" class="bg-indigo-700 bg-opacity-25 text-white px-6 py-3 rounded-lg font-medium hover:bg-opacity-50 transition duration-300">
                            <i class="fas fa-search mr-2"></i>索引
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="mermaid">
                        graph TD
                            A[数据库高级特性] --> B[视图]
                            A --> C[索引]
                            A --> D[触发器]
                            A --> E[存储过程]
                            B --> B1[虚拟表]
                            B --> B2[简化查询]
                            C --> C1[加速查询]
                            C --> C2[优化性能]
                            D --> D1[自动执行]
                            D --> D2[业务逻辑]
                            E --> E1[预编译]
                            E --> E2[复用性]
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-5xl px-4 md:px-0 py-12">
        <div class="flex flex-col md:flex-row">
            <!-- Table of Contents -->
            <aside class="md:w-1/4 pr-8 mb-10 md:mb-0">
                <div class="sticky top-8">
                    <h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <i class="fas fa-list-ul mr-2"></i>内容导航
                    </h2>
                    <ul class="space-y-2">
                        <li><a href="#views" class="toc-item text-gray-700 hover:text-indigo-600">视图概念与操作</a></li>
                        <li><a href="#indexes" class="toc-item text-gray-700 hover:text-indigo-600">索引原理与应用</a></li>
                        <li><a href="#triggers" class="toc-item text-gray-700 hover:text-indigo-600">触发器详解</a></li>
                        <li><a href="#procedures" class="toc-item text-gray-700 hover:text-indigo-600">存储过程指南</a></li>
                        <li><a href="#functions" class="toc-item text-gray-700 hover:text-indigo-600">数据库函数</a></li>
                    </ul>
                    
                    <div class="mt-8 bg-blue-50 p-6 rounded-lg">
                        <h3 class="font-bold text-blue-800 mb-3"><i class="fas fa-lightbulb mr-2"></i>关键要点</h3>
                        <ul class="space-y-2 text-sm text-blue-700">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>视图简化复杂查询，提高数据安全性</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>索引加速查询但会增加写入开销</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>触发器自动执行业务逻辑</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-blue-500 mt-1 mr-2"></i>
                                <span>存储过程预编译提高性能</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </aside>
            
            <!-- Content -->
            <main class="md:w-3/4">
                <!-- Views Section -->
                <section id="views" class="mb-16">
                    <div class="flex items-center mb-6">
                        <div class="feature-icon text-indigo-600 mr-4">
                            <i class="fas fa-eye text-xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">视图 (Views)</h2>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold text-gray-800 mb-4">什么是视图？</h3>
                            <p class="text-gray-700 mb-4">视图是基于一个表或多个表或视图的<strong>逻辑表</strong>，本身不包含数据，通过它可以对表里面的数据进行查询和修改。视图基于的表称为<strong>基表</strong>。</p>
                            <p class="highlight pl-4 bg-yellow-50 text-yellow-800 border-l-4 border-yellow-400 italic">视图是存储在数据字典里的一条SELECT语句。通过创建视图可以提取数据的逻辑上的集合或组合。</p>
                        </div>
                        
                        <div class="border-t border-gray-200 px-6 py-4 bg-gray-50">
                            <h4 class="font-semibold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-star text-yellow-500 mr-2"></i>视图优点
                            </h4>
                            <div class="grid md:grid-cols-2 gap-4">
                                <div class="bg-white p-4 rounded-lg border border-gray-200">
                                    <h5 class="font-medium text-indigo-600 mb-2">选择性访问</h5>
                                    <p class="text-sm text-gray-700">视图可以有选择性的选取数据库里的一部分数据，提高安全性</p>
                                </div>
                                <div class="bg-white p-4 rounded-lg border border-gray-200">
                                    <h5 class="font-medium text-indigo-600 mb-2">简化复杂查询</h5>
                                    <p class="text-sm text-gray-700">把复杂的查询变的简单，隐藏底层复杂性</p>
                                </div>
                                <div class="bg-white p-4 rounded-lg border border-gray-200">
                                    <h5 class="font-medium text-indigo-600 mb-2">数据独立性</h5>
                                    <p class="text-sm text-gray-700">维护数据的独立性，试图可从多个表检索数据</p>
                                </div>
                                <div class="bg-white p-4 rounded-lg border border-gray-200">
                                    <h5 class="font-medium text-indigo-600 mb-2">灵活视角</h5>
                                    <p class="text-sm text-gray-700">对于相同的数据可产生不同的视图</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-8">
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">创建视图</h3>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CREATE VIEW</span> 视图名称 <span class="text-purple-400">AS</span> 子查询
                                    </code>
                                </div>
                                <h4 class="font-medium text-gray-800 mb-2">示例1: 基本工资大于2000元的员工视图</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CREATE VIEW</span> v_emp <span class="text-purple-400">AS</span><br>
                                        <span class="text-purple-400">SELECT</span> * <span class="text-purple-400">FROM</span> emp <span class="text-purple-400">WHERE</span> sal > 2000;
                                    </code>
                                </div>
                            </div>
                        </div>
                        
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">查询视图</h3>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">SELECT</span> * <span class="text-purple-400">FROM</span> 视图名称;
                                    </code>
                                </div>
                                
                                <h3 class="text-xl font-semibold text-gray-800 mb-4 mt-6">修改视图</h3>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CREATE OR REPLACE VIEW</span> 视图名称 <span class="text-purple-400">AS</span> 查询语句<br>
                                        <span class="text-gray-500">-- 或者 --</span><br>
                                        <span class="text-purple-400">ALTER VIEW</span> 视图名称 <span class="text-purple-400">AS</span> 查询语句;
                                    </code>
                                </div>
                                
                                <h3 class="text-xl font-semibold text-gray-800 mb-4 mt-6">删除视图</h3>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">DROP VIEW</span> 视图名;
                                    </code>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
                
                <!-- Indexes Section -->
                <section id="indexes" class="mb-16">
                    <div class="flex items-center mb-6">
                        <div class="feature-icon text-green-600 mr-4">
                            <i class="fas fa-search text-xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">索引 (Indexes)</h2>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold text-gray-800 mb-4">索引概述</h3>
                            <p class="text-gray-700 mb-4"><strong>索引是一种特殊的文件，它们包含着对数据表里所有记录的引用指针。</strong>数据库索引是数据库管理系统中一个排序的数据结构，以协助快速查询、更新数据库表中数据。索引的实现通常使用B树及其变种B+树。</p>
                            <p class="text-gray-700">索引用于加快数据的检索，类似于书籍的索引。在数据库中索引可以减少数据库程序查询结果时需要读取的数据量，类似于在书籍中我们利用索引可以不用翻阅整本书即可找到想要的信息。</p>
                        </div>
                        
                        <div class="border-t border-gray-200 px-6 py-4 bg-gray-50">
                            <div class="grid md:grid-cols-2 gap-6">
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-3">索引类型</h4>
                                    <ul class="space-y-3">
                                        <li class="flex items-start">
                                            <span class="bg-green-100 text-green-800 text-xs font-medium px-2 py-1 rounded mr-2">主键</span>
                                            <span>数据列不允许重复，不允许为NULL，一个表只能有一个主键</span>
                                        </li>
                                        <li class="flex items-start">
                                            <span class="bg-blue-100 text-blue-800 text-xs font-medium px-2 py-1 rounded mr-2">唯一</span>
                                            <span>数据列不允许重复，允许为NULL值，一个表允许多个列创建唯一索引</span>
                                        </li>
                                        <li class="flex items-start">
                                            <span class="bg-purple-100 text-purple-800 text-xs font-medium px-2 py-1 rounded mr-2">单值</span>
                                            <span>给表中的某一个字段添加索引</span>
                                        </li>
                                        <li class="flex items-start">
                                            <span class="bg-indigo-100 text-indigo-800 text-xs font-medium px-2 py-1 rounded mr-2">组合</span>
                                            <span>给表中的多个字段添加索引，主要针对多条件查询</span>
                                        </li>
                                    </ul>
                                </div>
                                
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-3">创建索引语法</h4>
                                    <div class="code-block p-4 mb-3">
                                        <code class="text-gray-200 text-sm">
                                            <span class="text-yellow-400">-- 唯一索引 --</span><br>
                                            <span class="text-purple-400">ALTER TABLE</span> table_name <span class="text-purple-400">ADD UNIQUE</span> (column);
                                        </code>
                                    </div>
                                    <div class="code-block p-4 mb-3">
                                        <code class="text-gray-200 text-sm">
                                            <span class="text-yellow-400">-- 单值索引 --</span><br>
                                            <span class="text-purple-400">ALTER TABLE</span> `table_name` <span class="text-purple-400">ADD INDEX</span> index_name (`column`);
                                        </code>
                                    </div>
                                    <div class="code-block p-4">
                                        <code class="text-gray-200 text-sm">
                                            <span class="text-yellow-400">-- 组合索引 --</span><br>
                                            <span class="text-purple-400">ALTER TABLE</span> `table_name` <span class="text-purple-400">ADD INDEX</span> index_name (`column1`,`column2`);
                                        </code>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">索引操作</h3>
                                
                                <h4 class="font-medium text-gray-800 mb-2">查询索引</h4>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">SHOW INDEX FROM</span> table_name;
                                    </code>
                                </div>
                                
                                <h4 class="font-medium text-gray-800 mb-2">删除索引</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">ALTER TABLE</span> 表 <span class="text-purple-400">DROP INDEX</span> 索引名;
                                    </code>
                                </div>
                            </div>
                        </div>
                        
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">索引特性</h3>
                                
                                <div class="bg-blue-50 p-4 rounded-lg mb-4">
                                    <h4 class="font-medium text-blue-800 mb-2 flex items-center">
                                        <i class="fas fa-thumbs-up text-blue-500 mr-2"></i>优点
                                    </h4>
                                    <ul class="text-sm text-blue-700 space-y-1">
                                        <li>大大加快数据的检索速度</li>
                                        <li>通过唯一索引确保数据唯一性</li>
                                        <li>加速表与表之间的连接</li>
                                    </ul>
                                </div>
                                
                                <div class="bg-orange-50 p-4 rounded-lg">
                                    <h4 class="font-medium text-orange-800 mb-2 flex items-center">
                                        <i class="fas fa-exclamation-triangle text-orange-500 mr-2"></i>缺点
                                    </h4>
                                    <ul class="text-sm text-orange-700 space-y-1">
                                        <li>创建和维护索引要耗费时间</li>
                                        <li>索引需要占用物理空间</li>
                                        <li>降低增删改操作的性能</li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mt-8 bg-white rounded-xl shadow-md overflow-hidden">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold text-gray-800 mb-4">索引创建原则</h3>
                            <div class="grid md:grid-cols-2 gap-4">
                                <ul class="space-y-2 text-gray-700">
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                        <span>在经常需要搜索的列上创建索引</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                        <span>在作为主键的列上创建索引</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                        <span>在经常用在连接的列上创建索引</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                        <span>在经常需要排序的列上创建索引</span>
                                    </li>
                                </ul>
                                <ul class="space-y-2 text-gray-700">
                                    <li class="flex items-start">
                                        <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                        <span>避免在更新频繁的字段上创建索引</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                        <span>避免在查询中很少涉及的列上创建索引</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                        <span>避免在重复值比较多的列上创建索引</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                        <span>避免在text、image和bit类型的列上创建索引</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </section>
                
                <!-- Triggers Section -->
                <section id="triggers" class="mb-16">
                    <div class="flex items-center mb-6">
                        <div class="feature-icon text-red-600 mr-4">
                            <i class="fas fa-bolt text-xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">触发器 (Triggers)</h2>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold text-gray-800 mb-4">触发器概念</h3>
                            <p class="text-gray-700">在MySQL里面也就是对某一个表的一定的操作，触发某种条件（Insert, Update, Delete 等），从而自动执行的一段程序。和Web中学过的监听器很像。</p>
                        </div>
                        
                        <div class="border-t border-gray-200 px-6 py-4 bg-gray-50">
                            <h3 class="text-xl font-semibold text-gray-800 mb-4">创建触发器语法</h3>
                            <div class="code-block p-4">
                                <code class="text-gray-200 text-sm">
                                    <span class="text-purple-400">CREATE TRIGGER</span> trigger_name<br>
                                    trigger_time <span class="text-gray-500">-- BEFORE 或 AFTER</span><br>
                                    trigger_event <span class="text-gray-500">-- INSERT、UPDATE 或 DELETE</span><br>
                                    <span class="text-purple-400">ON</span> tbl_name<br>
                                    <span class="text-purple-400">FOR EACH ROW</span><br>
                                    trigger_stmt <span class="text-gray-500">-- 触发器程序体</span>
                                </code>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">触发器示例</h3>
                                <h4 class="font-medium text-gray-800 mb-2">例1: 自动同步数据</h4>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CREATE TRIGGER</span> triggen1<br>
                                        <span class="text-purple-400">AFTER INSERT ON</span> t1<br>
                                        <span class="text-purple-400">FOR EACH ROW</span><br>
                                        <span class="text-purple-400">INSERT INTO</span> t2(name) <span class="text-purple-400">VALUES</span>(new.name);
                                    </code>
                                </div>
                                
                                <div class="bg-blue-50 p-4 rounded-lg">
                                    <h5 class="font-medium text-blue-800 mb-2">NEW与OLD说明</h5>
                                    <ul class="text-sm text-blue-700 space-y-1">
                                        <li><strong>NEW</strong>: 新值，INSERT操作只有NEW</li>
                                        <li><strong>OLD</strong>: 旧值，DELETE操作只有OLD</li>
                                        <li>UPDATE操作既有NEW也有OLD</li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">触发器管理</h3>
                                
                                <h4 class="font-medium text-gray-800 mb-2">查看触发器</h4>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">SHOW TRIGGERS</span>;
                                    </code>
                                </div>
                                
                                <h4 class="font-medium text-gray-800 mb-2">删除触发器</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">DROP TRIGGER</span> 触发器的名字;
                                    </code>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
                
                <!-- Stored Procedures Section -->
                <section id="procedures" class="mb-16">
                    <div class="flex items-center mb-6">
                        <div class="feature-icon text-purple-600 mr-4">
                            <i class="fas fa-database text-xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">存储过程 (Stored Procedures)</h2>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold text-gray-800 mb-4">存储过程概述</h3>
                            <p class="text-gray-700">存储过程是能完成一定操作的一组SQL语句，它在创建后被有权限的用户在任何需要的地方调用。通过存储过程，不仅可以简化客户端应用程序的开发和维护，而且可以提高应用程序的运行性能。</p>
                        </div>
                        
                        <div class="border-t border-gray-200 px-6 py-4 bg-gray-50">
                            <h3 class="text-xl font-semibold text-gray-800 mb-4">创建存储过程基本语法</h3>
                            <div class="code-block p-4">
                                <code class="text-gray-200 text-sm">
                                    <span class="text-purple-400">CREATE PROCEDURE</span> 存储过程名字(<br>
                                    &nbsp;&nbsp;[<span class="text-purple-400">IN</span>] 参数1 参数类型, <span class="text-gray-500">-- 输入参数</span><br>
                                    &nbsp;&nbsp;<span class="text-purple-400">OUT</span> 参数2 参数类型 <span class="text-gray-500">-- 输出参数</span><br>
                                    ) <br>
                                    <span class="text-purple-400">BEGIN</span><br>
                                    &nbsp;&nbsp;程序代码块<br>
                                    <span class="text-purple-400">END</span>;
                                </code>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-8">
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">IN参数示例</h3>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">DELIMITER</span> // <span class="text-gray-500">-- 修改结束符</span><br>
                                        <span class="text-purple-400">CREATE PROCEDURE</span> pro1 (<br>
                                        &nbsp;&nbsp;<span class="text-purple-400">IN</span> u_id <span class="text-blue-400">INT</span>,<br>
                                        &nbsp;&nbsp;<span class="text-purple-400">IN</span> u_name <span class="text-blue-400">VARCHAR</span>(30),<br>
                                        &nbsp;&nbsp;<span class="text-purple-400">IN</span> u_age <span class="text-blue-400">INT</span><br>
                                        )<br>
                                        <span class="text-purple-400">BEGIN</span><br>
                                        &nbsp;&nbsp;<span class="text-purple-400">INSERT INTO</span> t_user(id,name,age) <span class="text-purple-400">VALUES</span>(u_id,u_name,u_age);<br>
                                        <span class="text-purple-400">END</span>;<br>
                                        //<br>
                                        <span class="text-purple-400">DELIMITER</span> ; <span class="text-gray-500">-- 恢复结束符</span>
                                    </code>
                                </div>
                                
                                <h4 class="font-medium text-gray-800 mb-2">调用存储过程</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CALL</span> pro1(1, '张三', 25);
                                    </code>
                                </div>
                            </div>
                        </div>
                        
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">OUT参数示例</h3>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CREATE PROCEDURE</span> pro2(<br>
                                        &nbsp;&nbsp;<span class="text-purple-400">IN</span> u_id <span class="text-blue-400">INT</span>,<br>
                                        &nbsp;&nbsp;<span class="text-purple-400">OUT</span> u_name <span class="text-blue-400">VARCHAR</span>(30)<br>
                                        )<br>
                                        <span class="text-purple-400">BEGIN</span><br>
                                        &nbsp;&nbsp;<span class="text-purple-400">SELECT</span> u.`name` <span class="text-purple-400">INTO</span> u_name <span class="text-purple-400">FROM</span> t_user u <span class="text-purple-400">WHERE</span> u.id = u_id;<br>
                                        <span class="text-purple-400">END</span>;
                                    </code>
                                </div>
                                
                                <h4 class="font-medium text-gray-800 mb-2">调用存储过程</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CALL</span> pro2(1, @name);<br>
                                        <span class="text-purple-400">SELECT</span> @name;
                                    </code>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">INOUT参数示例</h3>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CREATE PROCEDURE</span> pro5(<br>
                                        &nbsp;&nbsp;<span class="text-purple-400">INOUT</span> x <span class="text-blue-400">INT</span> <span class="text-gray-500">-- 即可作输入也可作输出</span><br>
                                        )<br>
                                        <span class="text-purple-400">BEGIN</span><br>
                                        &nbsp;&nbsp;<span class="text-purple-400">SET</span> x = x+10;<br>
                                        <span class="text-purple-400">END</span>;
                                    </code>
                                </div>
                                
                                <h4 class="font-medium text-gray-800 mb-2">调用存储过程</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">SET</span> @num = 5;<br>
                                        <span class="text-purple-400">CALL</span> pro5(@num);<br>
                                        <span class="text-purple-400">SELECT</span> @num; <span class="text-gray-500">-- 输出15</span>
                                    </code>
                                </div>
                            </div>
                        </div>
                        
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">存储过程管理</h3>
                                
                                <h4 class="font-medium text-gray-800 mb-2">查看存储过程</h4>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">SHOW CREATE PROCEDURE</span> 过程名称;
                                    </code>
                                </div>
                                
                                <h4 class="font-medium text-gray-800 mb-2">删除存储过程</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">DROP PROCEDURE</span> 储存过程名称;
                                    </code>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
                
                <!-- Functions Section -->
                <section id="functions">
                    <div class="flex items-center mb-6">
                        <div class="feature-icon text-indigo-600 mr-4">
                            <i class="fas fa-function text-xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">函数 (Functions)</h2>
                    </div>
                    
                    <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold text-gray-800 mb-4">创建函数基本语法</h3>
                            <div class="code-block p-4 mb-4">
                                <code class="text-gray-200 text-sm">
                                    <span class="text-purple-400">CREATE FUNCTION</span> 函数名(参数1 参数数据类型) <br>
                                    <span class="text-purple-400">RETURNS</span> 返回值类型 <br>
                                    <span class="text-purple-400">BEGIN</span> <br>
                                    &nbsp;&nbsp;<span class="text-purple-400">RETURN</span> 返回值; <br>
                                    <span class="text-purple-400">END</span>;
                                </code>
                            </div>
                            
                            <h4 class="font-medium text-gray-800 mb-2">调用函数</h4>
                            <div class="code-block p-4">
                                <code class="text-gray-200 text-sm">
                                    <span class="text-purple-400">SELECT</span> 函数名称(参数列表);
                                </code>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">简单函数示例</h3>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CREATE FUNCTION</span> fun1(<br>
                                        &nbsp;&nbsp;x <span class="text-blue-400">INT</span>,<br>
                                        &nbsp;&nbsp;y <span class="text-blue-400">INT</span><br>
                                        )<span class="text-purple-400">RETURNS</span> <span class="text-blue-400">INT</span><br>
                                        <span class="text-purple-400">BEGIN</span><br>
                                        &nbsp;&nbsp;<span class="text-purple-400">RETURN</span> x+y;<br>
                                        <span class="text-purple-400">END</span>;
                                    </code>
                                </div>
                                
                                <h4 class="font-medium text-gray-800 mb-2">调用函数</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">SELECT</span> fun1(3,5); <span class="text-gray-500">-- 返回8</span>
                                    </code>
                                </div>
                            </div>
                        </div>
                        
                        <div class="card bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6">
                                <h3 class="text-xl font-semibold text-gray-800 mb-4">带条件判断的函数</h3>
                                <div class="code-block p-4 mb-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">CREATE FUNCTION</span> fun3(<br>
                                        &nbsp;&nbsp;x <span class="text-blue-400">INT</span>,<br>
                                        &nbsp;&nbsp;y <span class="text-blue-400">INT</span><br>
                                        )<span class="text-purple-400">RETURNS</span> <span class="text-blue-400">INT</span><br>
                                        <span class="text-purple-400">BEGIN</span><br>
                                        &nbsp;&nbsp;<span class="text-purple-400">IF</span> x > y <span class="text-purple-400">THEN</span><br>
                                        &nbsp;&nbsp;&nbsp;&nbsp;<span class="text-purple-400">RETURN</span> x;<br>
                                        &nbsp;&nbsp;<span class="text-purple-400">ELSE</span><br>
                                        &nbsp;&nbsp;&nbsp;&nbsp;<span class="text-purple-400">RETURN</span> y;<br>
                                        &nbsp;&nbsp;<span class="text-purple-400">END IF</span>;<br>
                                        <span class="text-purple-400">END</span>;
                                    </code>
                                </div>
                                
                                <h4 class="font-medium text-gray-800 mb-2">调用函数</h4>
                                <div class="code-block p-4">
                                    <code class="text-gray-200 text-sm">
                                        <span class="text-purple-400">SELECT</span> fun3(3,5); <span class="text-gray-500">-- 返回5</span>
                                    </code>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            </main>
        </div>
    </div>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
        
        // 卡片悬停效果
        const cards = document.querySelectorAll('.card');
        cards.forEach(card => {
            card.addEventListener('mouseenter', () => {
                card.style.transform = 'translateY(-5px)';
                card.style.boxShadow = '0 10px 25px rgba(0, 0, 0, 0.1)';
            });
            card.addEventListener('mouseleave', () => {
                card.style.transform = '';
                card.style.boxShadow = '';
            });
        });
    </script>
</body>
</html>
```